from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from lxml import etree
import time
from time import sleep
opt = Options()
# opt.add_argument("--headless")
opt.add_argument("--disable-gpu")
opt.add_argument("--disable-blink-features=AutomationControlled")
web = webdriver.Chrome(options=opt)
base_url='http://scxk.nmpa.gov.cn:81/xk/'
web.get(url=base_url)

#page_source获取浏览器当前页面的页面源码数据
page_text = web.page_source
tree = etree.HTML(page_text)
li_list = tree.xpath('//ul[@id="gzlist"]/li')
for li in li_list:
    name = li.xpath('./dl/@title')[0]
    print(name)

#浏览器停留5秒之后关闭浏览器
sleep(5)
web.quit()